package com.letfox.ad.controller.ad;

import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.zip.GZIPOutputStream;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.letfox.ad.controller.BaseController;
import com.letfox.ad.util.ADUtil;

@Controller
@RequestMapping(value = "/adApi")
public class ADRequestAPIController extends BaseController{
	
	@RequestMapping(value = "/addPlanUser",method=RequestMethod.POST)
	@ResponseBody
	public String getGzip(@RequestParam String url){
		String str=null;
		String keyWord = null;
		 try { 
			 //gzip压解
			str=ADUtil.uncompress2(url);
			//URL转换
			keyWord = URLDecoder.decode(str, "UTF-8");
			System.out.println(keyWord);		
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto- generated catch block
			e.printStackTrace();
		}
		 return keyWord;
	}
	
	@RequestMapping(value = "/test",method=RequestMethod.POST)
	@ResponseBody
	public String test(@RequestParam String xmlData){
		return "接收到数据了"+xmlData;
	}
}

